import http from "@/utils/request"

// 获取所有角色
export function getAllRoles() {
  return http({
    url: '/authority/role',
    method: 'get'
  });
}

// 分页获取角色列表
export function getAllRolesByPages(page, size) {
  return http({
    url: `/authority/role/${page}/${size}`,
    method: 'get'
  })
}

// 确认添加角色
export function confirmAddRole(addRoleForm) {
  return http({
    url: '/authority/role',
    method: 'post',
    data: {
      "name": addRoleForm.name,
      "remarks": addRoleForm.remarks,
      "weight": addRoleForm.weight
    }
  })
}

// 查看角色的权限
export function checkoutRoleRights(id) {
  return http({
    url: `/authority/permission/rolePermission/${id}`,
    method: 'get'
  })
}

// 查看所有的权限
export function allRights() {
  return http({
    url: '/authority/permission',
    method: 'get'
  })
}

// 删除角色
export function deleteRole(id) {
  return http({
    url: `/authority/role/${id}`,
    method: 'delete'
  })
}

// 分配权限（修改角色）
export function editRole(id, name, permissionIds, remarks) {
  return http({
    url: '/authority/role',
    method: 'put',
    data: {
      "id": id,
      "name": name,
      "permissionIds": permissionIds,
      "remarks": remarks
    }
  })
}